home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
totsrc11.zip
/
TOTIO3.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-04
|
33KB
|
1,128 lines
{ Copyright 1991 TechnoJock Software, Inc. }
{ All Rights Reserved }
{ Restricted by License }
{ Build # 1.10 }
Unit totIO3;
{$I TOTFLAGS.INC}
{
Development Notes:
5/23/91 1.00a Added reaction to Mouse method 1
5/29/91 1.00b Corrected DEL when no chars in list
7/23/91 1.00c Corrected DEL when empty lines
2/06/91 1.00d Adjusted cursor when list/array assigned
10/02/92 1.00e Corrected backspace on empty linked list
}
INTERFACE
uses DOS, CRT,
totSYS, totLOOK, totFAST, totSTR, totINPUT, totLINK, totIO1;
TYPE
pWordwrapIOOBJ = ^WordwrapIOOBJ;
WordwrapIOOBJ = object(MultiLineIOOBJ)
vTopLine: integer; {number of first line in window}
vTotLines: integer; {total number of lines}
vListAssigned: boolean; {is data assigned}
vScrollBarOn: boolean; {is the vertical scrollbar required}
vBoxBorder: boolean; {is the data enclosed in a box}
vCursorX: byte; {position of cursor in Str}
vCursorY: byte; {line no. of cursor - from top}
vMaxLines: integer; {limit on total number of lines}
vLineStr: string; {copy of line being edited}
vInsert: boolean; {is field initially in insert mode}
vWidth: byte; {maximum width of an input string}
vEndKey: word; {key to jump to next field}
vAllowEdit: boolean; {can user change the text}
{methods ...}
constructor Init(X1,Y1,width,lines:byte;Title:string);
procedure WriteLine(OffSet:integer;Status:tStatus);
procedure SetEndKey(K:word);
procedure SetAllowEdit(On:boolean);
procedure DisplayAllLines(Status:tStatus);
procedure RefreshScrollBar(Status:tStatus);
procedure MoveCursor;
procedure CursorJump(Line:integer);
procedure CursorUp;
procedure CursorDown;
procedure CursorLeft;
procedure CursorRight;
procedure CursorPgUp;
procedure CursorPgDn;
procedure CursorHome;
procedure CursorEnd;
procedure CursorTop;
procedure CursorBottom;
procedure DeleteChar;
procedure Backspace;
procedure ProcessEnter;
function GetNextLinesLeadingSpaces(var StrOne,StrTwo: string;var LastLine: boolean): byte;
procedure GetNextLinesFullWords(var StrOne,StrTwo: string;var LastLine: boolean;Line:integer);
procedure PushWordsToNextLine(var StrOne,StrTwo: string;var LastLine: boolean;Line:integer);
procedure WrapFrom(Line: integer);
procedure AdjustMouseKey(var InKey: word;X,Y:byte);
procedure MouseChoose(X,Y:byte);
procedure ProcessChar(Ch:char);
procedure SetIns(InsOn:boolean);
procedure WrapFull; VIRTUAL;
function Select(K:word; X,Y:byte):tAction; VIRTUAL;
function ProcessKey(InKey:word;X,Y:byte):tAction; VIRTUAL;
procedure Display(Status:tStatus); VIRTUAL;
function Suspend:boolean; VIRTUAL;
function GetString(Line:integer): string; VIRTUAL;
procedure SetString(Line:integer;Str: string); VIRTUAL;
procedure DeleteLine(Line:integer); VIRTUAL;
procedure InsertLine(Line:integer); VIRTUAL;
procedure InsertAction(InsOn:boolean); VIRTUAL;
destructor Done; VIRTUAL;
end;
pWWArrayIOOBJ = ^WWArrayIOOBJ;
WWArrayIOOBJ = object (WordwrapIOOBJ)
vArrayPtr: pointer;
vStrLength: byte;
{methods ...}
constructor Init(X1,Y1,width,lines:byte;Title:string);
procedure AssignList(var StrArray; Total:Longint; StrLength:byte);
function GetString(Line:integer): string; VIRTUAL;
procedure SetString(Line:integer;Str: string); VIRTUAL;
procedure DeleteLine(Line:integer); VIRTUAL;
procedure InsertLine(Line:integer); VIRTUAL;
destructor Done; VIRTUAL;
end; {WWArrayIOOBJ}
pWWLinkIOOBJ = ^WWLinkIOOBJ;
WWLinkIOOBJ = object (WordwrapIOOBJ)
vLinkList: ^StrDLLOBJ;
vWrapping: boolean;
{methods ...}
constructor Init(X1,Y1,width,lines:byte;Title:string);
procedure AssignList(var LinkList: StrDLLOBJ; Max:integer);
procedure WrapFull; VIRTUAL;
function GetString(Line:integer): string; VIRTUAL;
procedure SetString(Line:integer;Str: string); VIRTUAL;
procedure DeleteLine(Line:integer); VIRTUAL;
procedure InsertLine(Line:integer); VIRTUAL;
destructor Done; VIRTUAL;
end; {WWLinkIOOBJ}
procedure IO3Init;
IMPLEMENTATION
{||||||||||||||||||||||||||||||||||||||||||||}
{ }
{ W W F i e l d O B J M E T H O D S }
{ }
{||||||||||||||||||||||||||||||||||||||||||||}
constructor WordwrapIOOBJ.Init(X1,Y1,width,lines:byte;Title:string);
{}
begin
MultiLineIOOBJ.Init(X1,Y1,width,lines,Title);
vTopLine := 1;
vTotLines := 0;
vListAssigned := false;
vScrollBarOn := false;
vCursorX := 1;
vCursorY := 1;
vInsert := IOTOT^.InputIns;
vEndKey := 324; {F10}
vAllowEdit := true;
end; {WordwrapIOOBJ.Init}
procedure WordwrapIOOBJ.SetEndKey(K:word);
{}
begin
vEndKey := K;
end; {WordwrapIOOBJ.SetEndKey}
procedure WordwrapIOOBJ.SetAllowEdit(On:boolean);
{}
begin
vAllowEdit := On;
end; {WordwrapIOOBJ.SetAllowEdit}
procedure WordwrapIOOBJ.WriteLine(OffSet:integer;Status:tStatus);
{}
var
Str : string;
A: byte;
begin
if vListAssigned then
begin
Str := GetString(pred(vTopLine)+OffSet);
Case Status of
HiStatus: A := IOTOT^.FieldCol(2);
Norm: A := IOTOT^.FieldCol(1);
else A := IOTOT^.FieldCol(4);
end; {case}
Screen.WriteAT(vBorder.X1,vBorder.Y1+pred(Offset),A,
padleft(Str,vBorder.X2-vBorder.X1,' '));
end;
end; {WordwrapIOOBJ.WriteLine}
procedure WordwrapIOOBJ.DisplayAllLines(Status:tStatus);
{}
var I: integer;
begin
for I := 1 to vRows do
WriteLine(I,Status);
if vCursorX > length(vLineStr) then
CursorEnd
else
MoveCursor;
end; {WordwrapIOOBJ.DisplayAllLines}
function WordwrapIOOBJ.Select(K:word; X,Y:byte): tAction;
{}
begin
vScrollBarOn := (vTotLines > vRows);
Display(HiStatus);
WriteMessage;
MoveCursor;
Select := none;
end; {WordwrapIOOBJ.Select}
procedure WordwrapIOOBJ.MoveCursor;
{}
begin
Screen.GotoXY(pred(vBorder.X1+vCursorX),pred(vBorder.Y1+vCursorY));
end; {WordwrapIOOBJ.MoveCursor}
procedure WordwrapIOOBJ.CursorJump(Line:integer);
{}
var
Tot: integer;
begin
Tot := vBorder.Y2 - succ(vBorder.Y1);
Line := Line - vBorder.Y1;
if vTotLines <= vRows then {all Lines on display}
begin
SetString(pred(vTopLine)+vCursorY,vLineStr);
vCursorY := (Line * vTotLines) div Tot;
vLineStr := GetString(pred(vTopLine)+vCursorY);
CursorHome;
MoveCursor;
end
else
begin
SetString(pred(vTopLine)+vCursorY,vLineStr);
vTopLine := (Line * vTotLines) div Tot;
vCursorY := 1;
vCursorX := 1;
MoveCursor;
vLineStr := GetString(pred(vTopLine)+vCursorY);
DisplayAllLines(HiStatus);
end;
end; {WordwrapIOOBJ.Cursor}
procedure WordwrapIOOBJ.CursorUp;
{}
begin
if vCursorY = 1 then
begin
if vTopLine > 1 then
begin
SetString(vTopLine,vLineStr);
dec(vTopLine);
vLineStr := GetString(vTopLine);
DisplayAllLines(HiStatus);
end;
end
else
begin